package ar.edu.itba.it.poo.dd.backend

class Player(var row: Int, var column: Int, val listener: BoardListener) extends Fighter(10, 5) {
  private var _level = 1
  def level = _level
  private var strengthBonus = 0
  var experience = 0
  def maxHealth = level * 10
  def requiredExperience = 5 * level
  var name = "Player"

  def accumExperience(ammount: Int) {
    experience += ammount
    if (experience >= requiredExperience) {
      _level += 1
      experience = 0
    }
  }

  override def fight(that: Fighter) {
    super.fight(that)
    if (!isAlive) listener.playerKilled
    if (!that.isAlive && that.level == 3) listener.bossDefeated
  }
  
  override def strength = level * 5 + strengthBonus

  def move(direction: Direction) {
    row += direction.y
    column += direction.x
  }
  
  def accumStrengthBonus(ammount: Int) = strengthBonus += ammount
}